<!DOCTYPE html>
<meta charset=x-user-defined>
<title>Regression test for crbug.com/661823</title>

<p>
  To test manually, create a local file named &#x13166;.txt then select it in the form
  and hit submit. If there is no crash, the test passes.
</p>

<form method=POST accept-charset="x-user-defined" enctype="multipart/form-data">
  <input type=file name=q>
  <input type=hidden name=submitted value=true>
  <input type=submit>
</form>

<script>
if (window.eventSender) {
  testRunner.dumpAsText();
  testRunner.waitUntilDone();
  window.onload = () => {
    if (window.location.search !== '?posted') {
      // Start the test
      var input = document.querySelector('input[type=file]');
      var rect = input.getClientRects()[0];
      var targetX = rect.left + rect.width / 2;
      var targetY = rect.top + rect.height / 2;
      eventSender.beginDragWithFiles(['\ud80c\udd66.txt']); // U+13166
      eventSender.mouseMoveTo(targetX, targetY);
      eventSender.mouseUp();
      var form = document.querySelector('form');
      form.action = window.location.href + '?posted';
      form.submit();
    } else {
      document.querySelector('p').innerText = 'PASS: did not crash';
      testRunner.notifyDone();
    }
  }
}
</script>
